package top.hmtools.mapper.plus.mysql;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * 注意修改：/hm-mapper-plus/src/test/resources/Test-Mybatis-config.xml 中数据库连接信息
 * @author Hybomyth
 *
 */
public class Common {

	/**
	 * 获取mybatis连接工厂
	 * @return
	 */
	public static SqlSessionFactory getSqlSessionFactory(){
		//设置mybatis配置文件
		String resource = "Test-Mybatis-config.xml";
		InputStream inputStream=null;
		try {
			inputStream = Resources.getResourceAsStream(resource);
		} catch (IOException e) {
			e.printStackTrace();
		}
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
		return sqlSessionFactory;
	}
}
